
<template>
  <div class="container">
    <div
      class="item"
      v-for="(item, index) in list"
      :key="index"
    >
      <div class="left">
        <div>
          <span>起息日期：</span>
          <span>{{ item.beginDate }}</span>
        </div>
        <div>
          <span>结息日期：</span>
          <span>{{ item.endDate }}</span>
        </div>
        <div>
          <span>周期：</span>
          <span>{{ item.days }}天</span>
        </div>
        <div>
          <span>付款时间：</span>
          <span>{{ item.payDate }}</span>
        </div>
        <div>
          <span>付款金额：</span>
          <span>{{ item.money }}</span>
        </div>
      </div>
    </div>
    <div class="load-more" v-if="!isEnd && !isEmpty">
      <van-button
        :loading="isLoading"
        loading-text="加载中..."
        type="default"
        @click="loadMore"
        >加载更多...</van-button
      >
    </div>
    <div class="no-data" v-if="isEnd && !isEmpty">
      <van-button plain type="default">没有更多了...</van-button>
    </div>
    <div v-if="isEnd && isEmpty" class="no-content">当前内容为空~</div>
  </div>
</template>

<script>
import { getPayList } from "@/api/order";
import { pagination, CUSTOMERTYPE } from "@/utils/enumConfig";
import { Dialog, Popup, Toast } from "vant";
export default {
  data() {
    return {
      CUSTOMERTYPE: CUSTOMERTYPE,
      pagination: this.$_.cloneDeep(pagination),
      list: [],
      isEnd: false,
      isEmpty: false,
      isLoading: false,
    };
  },
  async mounted() {
    await this.getPayList(this.pagination);
  },
  methods: {
    async loadMore() {
      let { current } = this.pagination;
      await this.getPayList({
        ...this.pagination,
        current: current + 1,
      });
    },
    async getPayList(pagination) {
      let orderId = this.$route.params.id;
      this.isLoading = true;
      let { size } = pagination;
      let list = await getPayList({ id:orderId,...pagination });
      if (list) {
        this.list = this.list.concat(list);
        this.pagination = pagination;
        this.isEnd = list.length < size ? true : false;
        this.isEmpty = this.list.length === 0 ? true : false;
      }
      this.isLoading = false;
    }
  },
};
</script>

<style lang="scss" scoped>
.status {
  position: absolute;
  right: 20px;
  top: 10px;
}
.item {
  position: relative;
  width: 100%;
  background: #fff;
  padding: 20px 0 0;
  color: #333;
  font-size: 14px;
  border-bottom: 1px solid #f1f1f1;
  margin-top: 10px;
  .left {
    margin-left: 20px;
    & > div {
      margin-bottom: 10px;
    }
  }
}
.load-more,
.no-data {
  width: 100%;
  button {
    width: 100%;
    color: #666;
  }
}
.fixed {
  position: fixed;
  bottom: 0;
  width: 100%;
  button {
    width: 100%;
  }
}
.container {
  padding-bottom: 20%;
}
.no-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #888;
}
</style>